import java.util.ArrayList;

public class Cart {
	ArrayList<Product> list = new ArrayList<>();
	protected double totalprice = 0;
	private int n = 0;
	
	public void AddToCart(Product flag){
		list.add(flag);
		n++;
	}
	
	public double getTotalprice(){
		for(int i = 0; i < n; i++){
			totalprice += list.get(i).getNum() * list.get(i).getPrice();
		}
		return totalprice;
	}

	@Override
	public String toString() {
		for(int i = 0; i < n; i++){
			System.out.println(list.get(i).toString());
		}
		return "";
	}

	
}
